//
//  NSString+GXAddition.m
//  CarSalesMS_GCX
//
//  Created by Ssky on 2016/11/7.
//  Copyright © 2016年 Tony. All rights reserved.
//

#import "NSString+GXAddition.h"

@implementation NSString (GXAddition)

- (NSString *)appendDocumentFilePath {
    NSString * doc = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
    return [doc stringByAppendingPathComponent:self];
}

//- (NSString *)append:(NSString *)str, ... {
////    va_list args;
////    va_start(args, str);
////    
////    NSString * obj = va_arg(args, NSString *);
////    
////    va_end(args);
////    
////    return [str stringByAppendingString:obj];
//}

- (BOOL)isEmpty {
    if ([self isEqualToString:@""]) {
        return YES;
    }
    return NO;
}

//- (NSString *)cutStringWithSeparator:(NSString *)separator {
//    [self ]
//}

- (NSString *)subStringFrontOfLastIndex:(NSInteger)index {
    NSInteger lastIndex = self.length - index;
    NSString * str = [self substringToIndex:lastIndex];
    return str;
}

- (NSString *)subStringBackOfLastIndex:(NSInteger)index {
    NSInteger lastIndex = self.length - index;
    NSString * str = [self substringFromIndex:lastIndex];
    return str;
}

- (NSString *)subStringFrontOfKey:(NSString *)key {
    NSRange range = [self rangeOfString:key];
    return [self substringToIndex:range.location];
}

- (NSString *)subStringBackOfKey:(NSString *)key {
    NSRange range = [self rangeOfString:key];
    return [self substringFromIndex:(range.location + range.length)];
}

@end
